# Maintainer: Konstantin Gizdov <arch at kge dot pw>
# Maintainer: T.J. Townsend <blakkheim@archlinux.org>
# Contributor: Markus Weimar <mail@markusweimar.de>

_pkgbase='iosevka'
_type='ttc'
pkgbase="${_type}-${_pkgbase}"
pkgname=(
    "${pkgbase}" "${pkgbase}-aile" "${pkgbase}-curly" "${pkgbase}-curly-slab" "${pkgbase}-etoile" "${pkgbase}-slab"
    "${pkgbase}-ss01" "${pkgbase}-ss02" "${pkgbase}-ss03" "${pkgbase}-ss04" "${pkgbase}-ss05" "${pkgbase}-ss06"
    "${pkgbase}-ss07" "${pkgbase}-ss08" "${pkgbase}-ss09" "${pkgbase}-ss10" "${pkgbase}-ss11" "${pkgbase}-ss12"
    "${pkgbase}-ss13" "${pkgbase}-ss14" "${pkgbase}-ss15" "${pkgbase}-ss16" "${pkgbase}-ss17" "${pkgbase}-ss18"
    )
pkgver=27.3.5
pkgrel=1
pkgdesc='Typeface family designed for coding, terminal use and technical documents.'
arch=('any')
url='https://typeof.net/Iosevka/'
license=('custom:OFL')
source=("${pkgbase}-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-${pkgver}.zip"
        "${pkgbase}-aile-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-aile-${pkgver}.zip"
        "${pkgbase}-curly-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-curly-${pkgver}.zip"
        "${pkgbase}-curly-slab-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-curly-slab-${pkgver}.zip"
        "${pkgbase}-etoile-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-etoile-${pkgver}.zip"
        "${pkgbase}-slab-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-slab-${pkgver}.zip"
        "${pkgbase}-ss01-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss01-${pkgver}.zip"
        "${pkgbase}-ss02-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss02-${pkgver}.zip"
        "${pkgbase}-ss03-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss03-${pkgver}.zip"
        "${pkgbase}-ss04-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss04-${pkgver}.zip"
        "${pkgbase}-ss05-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss05-${pkgver}.zip"
        "${pkgbase}-ss06-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss06-${pkgver}.zip"
        "${pkgbase}-ss07-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss07-${pkgver}.zip"
        "${pkgbase}-ss08-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss08-${pkgver}.zip"
        "${pkgbase}-ss09-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss09-${pkgver}.zip"
        "${pkgbase}-ss10-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss10-${pkgver}.zip"
        "${pkgbase}-ss11-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss11-${pkgver}.zip"
        "${pkgbase}-ss12-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss12-${pkgver}.zip"
        "${pkgbase}-ss13-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss13-${pkgver}.zip"
        "${pkgbase}-ss14-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss14-${pkgver}.zip"
        "${pkgbase}-ss15-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss15-${pkgver}.zip"
        "${pkgbase}-ss16-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss16-${pkgver}.zip"
        "${pkgbase}-ss17-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss17-${pkgver}.zip"
        "${pkgbase}-ss18-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss18-${pkgver}.zip"
        "${pkgbase}-${pkgver}-${pkgrel}-LICENSE.md::https://raw.githubusercontent.com/be5invis/Iosevka/v${pkgver}/LICENSE.md")
b2sums=('449247f95d696741c04c4b17f0d709eaa82d41570cc7a761d06bbdd36158e8d03a1f80fa7b7fb230bc1c7bdcc6e17cf356aaea85757a1ea73e897010beabb9e7'
        '572c635ff15256da85016dee9cbedd26ccce977d14f15850e7a6d6d62989f09d5f355692d613175216e0bee1116cc81135a3a492009ba9a9d53c1e70ab3be348'
        'e4b429e04c9d1e434b73a9a1b680a41015258140074a5806339e88ba6ddc4eee62906fdbd9b447d398279a30f17cae40ba4b82fa4d4384789808b4f1a7ab6e33'
        'a49657403317dcf925c323268dc1d2af34bee26aea91f38ae146a0ef863b0443e3d031427e5a12c93d7743f667294ce599e9d771825fd30571d7e70f36fc6c6b'
        'c3855189bb438f9e7f24ed81763d5f27026b46c97c26b3c43842ef9014a0c81614ed709704077771cafa9d1546a745cadeeb710f3bf45774490374749ac775a9'
        '162fae263ac8ba039393700bf6032e70116b2e3cd4de52c33c73acde4c21ce61607cff88b6cb16d4a08b139751c90f2fa355345388d25b64a08445f5837fa708'
        'fce8ce9b69c45dfe71436f2f9c4fdf2219db4c99eedf56b3ac6b3f4519d2669fabe16345312719603cc3741627c1fbf184dd9bc049af322db77e94e17b70d051'
        'cfa5206153f6b8ae0a5221bbd1ade35384566680d5c239efaa8195bcd7da976ae67ef3a15fdf52ca6fdef575be2267250795c4ae46b41a8948ef28613f8c64ba'
        'ea79868f7c3887212c23b02ae781882be61c9a4d83acbb3908ee438cc419fb6c3147177295b33ecab267cf83a1a08b50983c24de46635e0c6ed0001fa33c010b'
        '616ae1bdea38d606c46bf508f87d8f545a23889840ba3578d7c97168a94cf2ae179a8f0e2f7e66f2101b62ba0f84039b0f77931015e0de9724cbfb9e7d3439fb'
        'e1ee56488e88d19b3e3153673d01baee70b173179b6796f4c3a74265ccdbaa51847efbcee1e90f65f10d14af38e42d458db39accc3707293978d127ceab9f379'
        '1373e1458f4d3a9348f079f1b774214112488a4b41aedfe5153ca1be67e262136b3e0b37db85a7cc3e60cf990fef0409ad1d1ccf67ced809af3ab8db50e2b94b'
        'b20896f7d0864797e700cf11ed8c1aa05b570acb1a9b1562e4164e0df454f35257eefc6aae2be6caaf301d2fef5e7a8405d67000c4963a9ccaa7258b4d790c5b'
        '2cbaeb693e444e6cb71bb06d4e1260a74c16204dbb085fb5ea6f772d1c205593c5bb67c8c6df925e5fccc5d850ff9d86b5bd7cada14155e6a7d75c89f5c834c2'
        '718b00b4372c921df519efb61ef2695c0fc79e5413d97d4296ba466c30b7ec2609b248ade804063b9defe2e5d3d7e0f4cd801bdb7120e37d6b983dea4ab49b5b'
        '004d57bff8ae3e4db6ad75a4f72ceac843cb050503fd4112182c6c7a12a5136ab8a136e2e6a30ae9e2151e2219419647eab512738de98b9de3dbee00ce74875e'
        '279192ef3855ce9632aaf825463d3ae4ab09a782383e0eabe8d8b463ad42e2fc0ad7131e6a99f01b5e65140099c60f35072192dfadac35e9019cc7f5683ca062'
        '4d027f964d2d896f4d66347b71ebe19fbd10af9f0b4695ae05ea396533fd75daded3d653ccceba17648e6bb7dcdc872709a51ed6e16db2b700a2735c1f52cd7a'
        '98bf695359944c7fd966aa753d0aa0146679f6b6ed91abb5c8308c5a893f458a47ffc3b05330bf1fa111fb42f6671d9df23d1d10e0920679040156020485de71'
        'ec2c6463c3ab8c1b2cf6420b7cf77c7db515433316d7bacbda7c2b5f1e9f78f4fd4fda8e5c3f3734ad36be8ef9f7e65323285f89a8a6b5cd9746782b59c9db77'
        'fb8af30f0cd408399690327dc2c274ed70ad6178ce647e55df45c574937d37a00e1b2b4bfad1332cd3e5693d34b2006076bbb20a30505a84ca0ec3582d6b513a'
        'dd69a7dbaedbecc59b68b2e656c1737250a82e8c961a8fa1073d1b13bba21707a92a1201b3d70a2c2047d82817d1e312a09cb68ea28f0452c85b2ba6f74ee0e7'
        '667f1501d907a5be5da9db1dd33f2189b0b8c2e1d91fdf30c2fe34cf3303cd43c044ccd6e4de84a6b20b7c997fcc76dd6369894d642369b0bb7e455c32b33278'
        '5957207967e79467d134823c562275a26c812a2f6a1dd9149a08af0b84fc61e17ebbe6eab0c8ad2da1a32d48105d3ace6eded43ba631b23c850afb74f87a98e6'
        'c8d1b8e38801d7c1645eb250bc36922b7286b60d96be99f0bed2ce82939d299b343cca4a5767d2c1a1f11226326009828b49a11ce0ced9682af53e44a8afbc28')



function _package() {
    cd "${srcdir}/"
    local pkgnm="${1}"
    local fontname="${pkgnm#${_type}-}"
    local fontvar="${pkgnm#${pkgbase}-}"
    fontvar="${fontvar^}"
    install -d "${pkgdir}"/usr/share/fonts/TTF
    install -m644 "${fontname}"-*.ttc "${pkgdir}"/usr/share/fonts/TTF/
    install -d "${pkgdir}"/usr/share/licenses
    if [[ "${pkgnm}" == "${pkgbase}" ]]; then
        rm -rf "${pkgdir}/usr/share/fonts/TTF"/*{aile,curly,etoile,slab,ss}*
    else
        if [[ "${pkgnm}" == "${pkgbase}-curly" ]]; then
            rm -rf "${pkgdir}/usr/share/fonts/TTF"/*curly-slab*
        fi
        if [[ "${pkgnm}" == "${pkgbase}-curly-slab" ]]; then
            pkgdesc+=" (Curly Slab variant)"
        else
            pkgdesc+=" (${fontvar} variant)"
        fi
    fi
    install -D -m644 "${pkgbase}-${pkgver}-${pkgrel}-LICENSE.md" "${pkgdir}/usr/share/licenses/${pkgnm}/LICENSE.md"
}

for _pkgname in ${pkgname[@]}; do
    eval "function package_$_pkgname() { _package $_pkgname; }"
done
